// 导入数据库操作模块
const db = require('../db/index')

exports.getFirPartCT = (req, res) => {
    const sql = `select distinct firPart from ct;`
    db.query(sql, (err, results) => {
        if (err) return res.er(err.message)
        res.send({
            status: 0,
            message: '获取列表成功！',
            data: results,
            total: results.length,
        })
    })
}
exports.getFirPartMRI = (req, res) => {
    const sql = `select distinct firPart from mri;`
    db.query(sql, (err, results) => {
        if (err) return res.er(err.message)
        res.send({
            status: 0,
            message: '获取列表成功！',
            data: results,
            total: results.length,
        })
    })
}

exports.getSecPartCT = (req, res) => {
    const sql = `select distinct secPart from ct where firPart= ?;`
    db.query(sql, req.body.firPart, (err, results) => {
        if (err) return res.er(err.message)
        res.send({
            status: 0,
            message: '获取列表成功！',
            data: results,
            total: results.length,
        })
    })
}

exports.getSecPartMRI = (req, res) => {
    const sql = `select distinct secPart from mri where firPart= ?;`
    db.query(sql, req.body.firPart, (err, results) => {
        if (err) return res.er(err.message)
        res.send({
            status: 0,
            message: '获取列表成功！',
            data: results,
            total: results.length,
        })
    })
}